package com.xz.group12306.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.xz.group12306.business.service.ManagerService;
import com.xz.group12306.business.service.impl.ManagerServiceImpl;
import com.xz.group12306.domain.Ticket;

/**
 * 管理员查询车票Servlet
 */
@WebServlet("/ManageQueryTicketServlet")
public class ManageQueryTicketServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * 构造方法
	 */
	public ManageQueryTicketServlet() {
		super();
	}

	/**
	 * doGet方法
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		int pageSize = Integer.parseInt(request.getParameter("pageSize"));
		int start = Integer.parseInt(request.getParameter("start"));
		String depature = request.getParameter("depature");
		String destiction = request.getParameter("destiction");
		Ticket ticket = new Ticket();
		
		ticket.setDepature(depature);
		ticket.setDestinction(destiction);
		ManagerService managerService=new ManagerServiceImpl();
		List<Ticket> tickets = managerService.findTicketList(ticket, start, pageSize);

		HttpSession session = request.getSession();
		session.setAttribute("tickets", tickets);
		response.sendRedirect("admin/ManageQueryTicket.jsp");
	}

	/**
	 * doPost方法
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
